package demo1229.chenweiqun;
public class Customer extends Thread {
    private Baozi baozi;

    public Customer(Baozi baoZi) {
        this.baozi = baoZi;
    }

    @Override
    public void run() {
        while (true) {
            synchronized (baozi) {
                if (!baozi.isExist()) {
                    try {
                        baozi.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("吃" + baozi.getPi() + baozi.getXian() + "包子");
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                baozi.setExist(false);
                baozi.notify();
            }
        }
    }
}
